package model;

import java.util.List;

import DTO.PassengerDTO;

/**
 * This is an interface that provides a complete business transactions with 
 * an entity of Passenger
 */
public interface Passenger {

	/**
	 * This method checks the DTO for uniqueness and if it's so, it adds a new 
	 * Passenger entity to DB with instances equal to the original DTO
	 * 
	 * @param passenger	- DTO of passenger which is required to be registered
	 * @return			- a new created Passenger entity or null if check
	 * 					  for uniqueness failed
	 */
	public model.impl.Passenger registrationOfNewPassenger(
			PassengerDTO passenger);

	/**
	 * This method checks if there is a passenger in DB which has the same 
	 * login and password as a received DTO, and if it's so it logs in this
	 * passenger.
	 * 
	 * @param passenger - DTO of passenger which is required to be logged in
	 * @return			- DTO that is associated with found Passenger entity
	 * 					  or null if the search failed.
	 */
	public PassengerDTO loginOfExistingPassenger(PassengerDTO passenger);

	/**
	 * This method checks if there is a passenger in DB which has the same 
	 * ID as a received DTO. If a passenger entity is found in DB, method 
	 * removes it.
	 * 
	 * @param passengerDTO - DTO of passenger which is required to be removed
	 */
	public void removeUniquePassenger(PassengerDTO passengerDTO);

	/**
	 * This method checks if there is a passenger in DB which has the same 
	 * login and password as a received DTO and which is currently logged in.
	 * If it's found, method logs it out.
	 * 
	 * @param passengerDTO - DTO of passenger which is required to be logged out
	 * @return			   - true if passenger was logged out or false in any
	 * 						 other cases
	 */
	public boolean logOutOfExistingPassenger(PassengerDTO passengerDTO);

	/**
	 * This method checks if there is a passenger in DB which has the same 
	 * ID as a received DTO and which is currently logged in. If it's found, 
	 * method return DTO object that represent all the instances of found 
	 * passenger entity.
	 * 
	 * @param passenger	- DTO of passenger which is required to be refreshed
	 * @return			- DTO that is associated with refreshed Passenger entity
	 * 					  or null in any other cases.
	 */
	public PassengerDTO refreshPassengerInfo(PassengerDTO passenger);

	/**
	 * Method looks for all the Passenger entities in DB.
	 * @return	- List of all Passenger entities in DB or null if there is no
	 * 			  passengers in DB.
	 */
	public List<model.impl.Passenger> findAll();
	
	/**
	 * Looks for a Passenger with the passenger's instances equals to the 
	 * given parameters. It's as is PassengerDAO method wrapped with 
	 * transaction.
	 * 
	 * @param login	- Passenger.login
	 * @return		- Passenger entity object or null if such object was
	 * 				  not found
	 */
	public model.impl.Passenger findPassengerByLogin(String login);
	
	/**
	 * This method checks if there is a passenger in DB which has the same 
	 * ID as the given DTO. If it is found in DB, method modify its instances
	 * according to the given DTO.
	 * 
	 * @param passengerDTO - DTO of passenger which is required to be modified
	 */
	public void modifyUniquePassenger(PassengerDTO passengerDTO);
}
